package com.ocom.payconfig.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ocom.common.entity.payconfig.EntityMealMenu;
import com.ocom.common.entity.payconfig.EntityReceiptAddress;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface IDaoReceiptAddress extends BaseMapper<EntityReceiptAddress> {

    @Select({"<script>",
            "select " +
                    "receipt_id, " +
                    "com_id, " +
                    "receipt_name, " +
                    "parent_receipt_id, " +
                    "receipt_orgin, " +
                    "remark, " +
                    "create_time, " +
                    "create_user, " +
                    "update_time, " +
                    "update_user, " +
                    "status " +
                    "from receipt_address " +
                    "where com_id = #{comId}  " +
                    "<when test=\"receiptId != null and  receiptId &gt; -1\" > " +
                    "and  receipt_id = #{receiptId}  " +
                    " </when> " +
                    "<when test=\"parentReceiptId != null and  parentReceiptId &gt; -1\" > " +
                    "and  parent_receipt_id = #{parentReceiptId}  " +
                    " </when> " +
                    "<when test=\"receiptName != null \" > " +
                    "and  receipt_name = #{receiptName}  " +
                    " </when> " +
                    "</script>"})
    public List<EntityReceiptAddress> getAdReceiptInfo(@Param("comId") Long comId,
                                                       @Param("receiptId") Integer receiptId,
                                                       @Param("parentReceiptId") Integer parentReceiptId,
                                                       @Param("receiptName") String receiptName);
}
